#include "Date.h"

const int Date::_monthDay[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

bool Date::isLeapYear(int year)
{
	return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
}

bool Date::isLeapYear()
{
	return isLeapYear(_year);
}

int Date::getMonthDay(int year, int month)
{
	if (month == 2 && isLeapYear(year))
	{
		return 29;
	}

	return _monthDay[month];
}

int Date::getMonthDay()
{
	return getMonthDay(_year, _month);
}

bool Date::isRightDate(int year, int month, int day)
{
	if (year < 1)
	{
		return false;
	}
	if (month < 1 || 12 < month)
	{
		return false;
	}
	if (day < 1 || getMonthDay(year, month) < day)
	{
		return false;
	}

	return true;
}

bool Date::isRightDate()
{
	return isRightDate(_year, _month, _day);
}

void Date::print()
{
	std::cout << _year << "/" << _month << "/" << _day << std::endl;
}